const createThemeColorReplacerPlugin = require('./config/plugin.config')
// const apiMall = 'http://172.31.13.52:9081'
// const apiMall = 'http://192.168.10.243:9081'
const apiMall = 'https://portal.ncpu.edu.cn'
// const apiMall = 'http://testncdd.siyuanv.com'
const path = require('path')
const moment = require('moment')
const packInfo = require('./package')
function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  configureWebpack: {
    plugins: [createThemeColorReplacerPlugin()]
  },
  devServer: {
    port: 8002,
    proxy: {
      '/dev-api': {
        target: apiMall,
        changeOrigin: true,
        pathRewrite: {
          '^/dev-api': '/api' //这里是用'/api'来代替 target中的地址，例如要调用“http://localhost:8443/qml/?greate=100”那么直接写成'/api/qml/?greate=100'
        }
	    },
      //仅用于/cas/serviceValidate接口
     '/cas': {
        target: apiMall,
        changeOrigin: true,
        secure:false,
        pathRewrite: {
          '^/dev-api': '' //这里是用'/api'来代替 target中的地址，例如要调用“http://localhost:8443/qml/?greate=100”那么直接写成'/api/qml/?greate=100'
        }
      }
    }
  },
  css: {
    loaderOptions: {
      less: {
        modifyVars: {},
        javascriptEnabled: true
      },
      // 给 stylus-loader 传递选项
      stylus: {
        import: '~@/assets/styles/global.styl'
      }
    }
  },
  chainWebpack: config => {
    //alias config
    config.resolve.alias
      .set('@assets', resolve('src/assets'))
      .set('@clientAssets', resolve('src/assets/client'))
      .set('@client', resolve('src/pages/clientViews'))
    // build tag for webpack
    config.plugin('define').tap(args => {
      let date = moment().format('YYYY-MM-DD HH:mm:ss')
      args[0].API_CONFIG = JSON.stringify({
        projectName: packInfo.name,
        version: date
      })
      return args
    })
  }
}


    // "@antv/data-set": "^0.11.8",
    // "ant-design-vue": "^1.7.5",
